package geowiki.data;

import geowiki.vis.PlaceMarker;

import java.util.ArrayList;
import java.util.List;

import processing.core.PApplet;

/**
 * A Link is the extracted anchor of a HTML document. Parsed from a Wikipedia article.
 */
public class Link {

	public String url;
	public String title;
	public List<PlaceMarker> storedPlaceMarkers = new ArrayList<PlaceMarker>();
	PApplet p;

        //arg nich schön aber erstmal bequem..
        int offset=200;

	public Link(String title, String url, PApplet p) {
		super();
		this.url = url;
		this.title = title;
		this.p = p;
	}

	public String toString() {
		return title + " (url:" + url + ")";
	}

	public void storePlaceMarkers(List<Place> newPlaces) {
		storedPlaceMarkers = createPlaceMarkers(newPlaces);
	}

	List<PlaceMarker> createPlaceMarkers(List<Place> places) {
		List<PlaceMarker> placeMarkers = new ArrayList<PlaceMarker>();

		for (int i = 0; i < places.size(); i++) {

			Place place = places.get(i);
			PlaceMarker placeMarker = new PlaceMarker(p, place,offset);
			placeMarkers.add(placeMarker);
		}
		return placeMarkers;
	}

}